package cn.openea.perpartner.evaluation.web.mapper;

import cn.openea.perpartner.evaluation.web.entity.EvaluationTask;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author rains
 * @since 2023-07-05 14:22
 */
public interface EvaluationTaskMapper extends BaseMapper<EvaluationTask> {

    /**
     * 活动结束时间到结束测评任务
     * 次日8:20
     * @return
     */
    @Select("select * from meily_evaluation_task where task_status = '1' and datediff(end_time, DATE_FORMAT(now(), '%Y-%m-%d')) <= -1 ORDER BY end_time")
    List<EvaluationTask> getNeedToEndTask();

    /**
     * 评级时间到发送评级待办
     * 评级时间的当天8:20给评级人发放评级待办
     * @return
     */
    @Select("select * from meily_evaluation_task where task_status = '1' and datediff(rating_time, DATE_FORMAT(now(), '%Y-%m-%d')) <= 0 ORDER BY rating_time")
    List<EvaluationTask> getNeedToSendatingTodo();

    /**
     * 获取已结束一个月的样品任务
     * 任务状态。0:正常结束(到期自动结束)；1:正在进行中；2:报名结束；3:活动作废(手动结束)
     */
    @Select("select * from meily_evaluation_task where task_status in ('0','3') and DATE_FORMAT(date_add(create_time, interval 1 month), '%Y-%m-%d') = DATE_FORMAT(now(), '%Y-%m-%d') ORDER BY create_time")
    List<EvaluationTask> getEndAMonthTaskList();
}

